package com.tools.cleanmaster.manager;

import com.hm.base.android.mob.AMApplication;
import com.hm.base.android.mob.MobBeanManager;
import com.tools.cleanmaster.CleanApplication;
import com.tools.cleanmaster.cache.CleanRawCache;
import com.tools.cleanmaster.store.CleanSharedPrefManager;

/**
 * desc:
 * date: 2018/4/16
 * author: ancun
 */

public class CleanBeanManager extends MobBeanManager {

    private CleanApplication mCleanApplication;

    public CleanBeanManager(AMApplication imContext) {
        super(imContext);
        mCleanApplication = (CleanApplication) imContext;
    }

    @Override
    protected <T> T createBean(Class<T> clazz, String mark) {
        Object obj;
        if (clazz == CleanSharedPrefManager.class) {
            obj = new CleanSharedPrefManager(mCleanApplication);

        } else if (clazz == ChargingManager.class) {
            obj = new ChargingManager(mCleanApplication);

        } else if (clazz == AutoCleanManager.class) {
            obj = new AutoCleanManager(mCleanApplication);

        } else if (clazz == CleanRawCache.class) {
            obj = new CleanRawCache();

        } else {
            obj = super.createBean(clazz, mark);
        }

        return (T) obj;
    }

    public CleanSharedPrefManager getCleanSharedPrefManager() {
        return getBean(CleanSharedPrefManager.class);
    }

    public ChargingManager getChargingManager() {
        return getBean(ChargingManager.class);
    }

    public AutoCleanManager getAutoCleanManager() {
        return getBean(AutoCleanManager.class);
    }

    public CleanRawCache getCleanRawCache() {
        return getBean(CleanRawCache.class);
    }

}
